﻿namespace SocketServer.SocketResult
{
    /// <summary>
    /// Socket以Json的方式输出给前端
    /// </summary>
    public class SocketByteResult : ISocketResult
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Data">返回数据</param>
        public SocketByteResult(byte[] Data)
        {
            this.Data = Data;
        }

        /// <summary>
        /// 返回数据
        /// </summary>
        private byte[] Data { get; }

        /// <inheritdoc/>
        public object GetData()
        {
            return Data;
        }

        /// <summary>
        /// Socket方法项前端输出数据的方式
        /// </summary>
        /// <param name="webSocket">webSocket链接</param>
        public void SendResult(Fleck.IWebSocketConnection webSocket)
        {
            webSocket.Send(Data);
        }
    }
}
